package com.sinodata.bsm.cicp.util.telnet;

import java.io.IOException;

/**
 * Login 任务.
 * 
 * @author thomas.h.zhang
 */
public class LoginTask extends TelnetTask {
    private String user;
    private String pwd;
    private String prompt;

    public LoginTask(Telnet telnet, String user, String pwd, String prompt) {
        this.telnet = telnet;
        this.user = user;
        this.pwd = pwd;
        this.prompt = prompt;
    }

    public void run() {
        try {
            telnet.login(user, pwd, prompt);
            shellOut = telnet.recvResp();
            this.setComplete(true);
        } catch (IOException e) {
            this.setError(true);
            this.setErrorMsg(e.getMessage());
            this.setComplete(false);
        }
        this.setActive(false);
        return;
    }
}
